[ENH] Implement dynamic docstring formula injection for distributions#1024
Open
KaranSinghDev wants to merge 2 commits intosktime:mainfrom
Open
[ENH] Implement dynamic docstring formula injection for distributions#1024KaranSinghDev wants to merge 2 commits intosktime:mainfrom
KaranSinghDev wants to merge 2 commits intosktime:mainfrom
Conversation
fkiraly
requested changes
Apr 4, 2026
Collaborator
fkiraly
left a comment
There was a problem hiding this comment.
Somehow your approach causes recursion in the pdf method. I suspect this might be due to how this interacts with _has_implementation_of?
Contributor
Author
|
@fkiraly Thank you for the observation. I have checked it and I overrode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
#689 #698
What does this implement/fix? Explain your changes.
A robust mechanism to inject distribution-specific LaTeX formulas into the generic public methods of BaseDistribution (e.g., pdf, cdf, mean, var, energy).
Key things done:
Fallback (Weibull PDF)

Injected Math (Rayleigh PDF - custom)

Does your contribution introduce a new dependency? If yes, which one?
No
What should a reviewer concentrate their feedback on?
1.The robustness of the init_subclass implementation.
2. The indentation logic in _inject_formula_doc which was designed to fix the rendering failures discussed in #698.
3. The demonstration implementations in Normal, Rayleigh, Exponential, and Laplace.
Did you add any tests for the change?
Implemented a comprehensive suite in skpro/distributions/tests/test_docstring_injection.py verifying:
1.Injection in hooked classes.
2.Clean fallback (placeholder removal) in unhooked classes across all 12 methods.
3. Execution safety and metadata integrit
Any other comments?
I have implemented the hooks for 4 major distributions. If this approach is decent, I would be happy to extend the formulas to the rest of the distribution registry.
@fkiraly, please let me know if this mechanism meets the project's standards for the documentation pipeline.
P.S @fkiraly this could have been done earlier but I was submitting the abstract of my research project thus the delay.
PR checklist
For all contributions
How to: add yourself to the all-contributors file in the
skproroot directory (not theCONTRIBUTORS.md). Common badges:code- fixing a bug, or adding code logic.doc- writing or improving documentation or docstrings.bug- reporting or diagnosing a bug (get this pluscodeif you also fixed the bug in the PR).maintenance- CI, test framework, release.See here for full badge reference
For new estimators
docs/source/api_reference/taskname.rst, follow the pattern.Examplessection.python_dependenciestag and ensureddependency isolation, see the estimator dependencies guide.